﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RepairModelProblemListCtrl.ascx.cs" Inherits="WebUI.Controls.RepairModelProblemListCtrl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<script type="text/javascript">
var <%=ClientID %>clickOnCheckbox;
var <%=ClientID %>selectedRow = null;       
var <%=ClientID %>selectedCheckbox = null; 
var <%=ClientID %>selectedID = null; 
var <%=ClientID %>selectedClass = null; 

function resetGridSelection<%=ClientID %>(){
    <%=ClientID %>selectedRow = null;   
    if(<%=ClientID %>selectedCheckbox != null)
        <%=ClientID %>selectedCheckbox.checked = false;          
    <%=ClientID %>selectedCheckbox = null; 
    <%=ClientID %>selectedID = null; 
    <%=ClientID %>selectedClass = null; 
}

function clickOnCheckBox<%=ClientID %>(cb){
    <%=ClientID %>clickOnCheckbox = true;
}

function onItemClick<%=ClientID %>(sender)
    {
        var hidSelectedID = document.getElementById("<%= hidSelectedID.ClientID %>");
        if(<%=ClientID %>clickOnCheckbox){
            <%=ClientID %>clickOnCheckbox = false;
            return;
        }

        if(<%=ClientID %>selectedRow == null){
            <%=ClientID %>selectedRow = document.getElementById("<%=ClientID %>" + "_row_" + hidSelectedID.value);
        }
        
        if(<%=ClientID %>selectedRow != null){
            if(<%=ClientID %>selectedRow.className)
                <%=ClientID %>selectedRow.className = <%=ClientID %>selectedRow.getAttribute("orgclass");
            else
                <%=ClientID %>selectedRow.setAttribute("class", <%=ClientID %>selectedClass);
            if(<%=ClientID %>selectedCheckbox != null)
                <%=ClientID %>selectedCheckbox.checked = false;
            else{
                var chks = <%=ClientID %>selectedRow.getElementsByTagName("input");
                 for(var i = 0; i < chks.length; i++){
                    if(chks[i].type == "checkbox" && chks[i].id.indexOf("cbSelect") >= 0){
                        chks[i].checked = false;
                        break;
                    }
                }
            }
        }
        
        if(sender.className){
            sender.className = "CustomGridSelectedItem";
        }
        else{
            <%=ClientID %>selectedClass = sender.getAttribute("class");
            sender.setAttribute("class", "CustomGridSelectedItem");
        }
        <%=ClientID %>selectedRow = sender;
        
        var inputs = sender.getElementsByTagName("input");
        for(var i = 0; i < inputs.length; i++){
            if(inputs[i].type == "checkbox" && inputs[i].id.indexOf("cbSelect") >= 0){
                <%=ClientID %>selectedCheckbox = inputs[i];
                inputs[i].checked = true;
                break;
            }
        }

        hidSelectedID.value = <%=ClientID %>selectedRow.getAttribute("ItemID");
    }

    function selectAll<%=ClientID %>(cbAll){
        var grid = document.getElementById("<%=grid.ClientID %>");
        var inputs = grid.getElementsByTagName("input");
        for(var i = 0; i < inputs.length; i++){
            if(inputs[i].type == "checkbox"){
                inputs[i].checked = cbAll.checked;
            }
        }
    }

     function getSelectedItemID<%=ClientID %>(){
        if(document.getElementById("<%= hidSelectedID.ClientID %>").value == "")
            return null;
        return document.getElementById("<%= hidSelectedID.ClientID %>").value;
    }

</script>

<%--start modify here--%>



<asp:DataGrid ID="grid" runat="server" AllowPaging="true" AllowSorting="true" GridLines="None" class="customGrid" ShowFooter="true"
AutoGenerateColumns="false" EmptyDataText="No record to display" ItemStyle-Wrap="true" CellPadding="1" CellSpacing="1"
OnSortCommand="grid_OnSortCommand" OnItemCreated="grid_OnItemCreated" OnItemDataBound="grid_OnItemDataBound" 
OnPageIndexChanged="grid_OnPageIndexChanged" AllowCustomPaging="true" UseAccessibleHeader="true" DataKeyField="ID">
<PagerStyle Mode="NumericPages" PageButtonCount="10"   />
<Columns>
    <asp:TemplateColumn ItemStyle-Width="20px" HeaderStyle-Width="20px" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
        <HeaderTemplate><asp:CheckBox ID="cbSelectAll" runat="server" /></HeaderTemplate>
        <ItemTemplate>
            <asp:CheckBox ID="cbSelect" runat="server" ItemID='<%# Eval("ID") %>' />
        </ItemTemplate>
    </asp:TemplateColumn>
    <%--start modify here--%>
    <asp:BoundColumn ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="150px" DataField="ID" SortExpression="ID" HeaderText="ID" Visible="false"></asp:BoundColumn>
    
    <asp:TemplateColumn HeaderText="Problem" ItemStyle-Width="200px" HeaderStyle-Width="200px"  ItemStyle-HorizontalAlign="Left"  HeaderStyle-HorizontalAlign="Left" >
        <ItemTemplate>
            <asp:Label ID="lblProbName" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
        </ItemTemplate>
    </asp:TemplateColumn>

     <asp:TemplateColumn HeaderText="RRP" ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Right"  HeaderStyle-HorizontalAlign="Left" >
        <%--<ItemTemplate>
            
        </ItemTemplate>--%>
        <ItemTemplate>
            <asp:Label ID="lblRPP" runat="server" Text='<%# Eval("RPP") %>'></asp:Label>
            <asp:TextBox ID="txtRPP" runat="server"  Width="60px" Text='<%# Eval("RPP").ToString() %>'></asp:TextBox>
            <cc1:FilteredTextBoxExtender FilterType="Numbers, Custom" ValidChars="." TargetControlID="txtRPP"
                ID="FilteredTextBoxExtenderRPP" runat="server">
            </cc1:FilteredTextBoxExtender>
        </ItemTemplate>
    </asp:TemplateColumn>

    <asp:TemplateColumn HeaderText="Standard Price" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right"  HeaderStyle-HorizontalAlign="Left" >
        <%--<ItemTemplate>
             
        </ItemTemplate>--%>
        <ItemTemplate>
            <asp:Label ID="lblStandardPrice" runat="server" Text='<%# Eval("StandardPrice") %>'></asp:Label>
            <asp:TextBox ID="txtStandardPrice" Width="60px" runat="server" Text='<%# Eval("StandardPrice").ToString() %>' ></asp:TextBox>
            <cc1:FilteredTextBoxExtender FilterType="Numbers, Custom" ValidChars="." TargetControlID="txtStandardPrice"
                ID="FilteredTextBoxExtenderStandardPrice" runat="server">
            </cc1:FilteredTextBoxExtender>
        </ItemTemplate>
    </asp:TemplateColumn>

    <asp:TemplateColumn HeaderText="Special Price" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Left" >
        <%--<ItemTemplate>
            
        </ItemTemplate>--%>
        <ItemTemplate>
            <asp:Label ID="lblSpecialPrice" runat="server" Text='<%# Eval("SpecialPrice") %>'></asp:Label>
            <asp:TextBox ID="txtSpecialPrice"  Width="60px" runat="server" Text='<%# Eval("SpecialPrice").ToString() %>'></asp:TextBox>
            <cc1:FilteredTextBoxExtender FilterType="Numbers, Custom" ValidChars="." TargetControlID="txtSpecialPrice"
                ID="FilteredTextBoxExtenderSpecialPrice" runat="server">
            </cc1:FilteredTextBoxExtender>
        </ItemTemplate>
    </asp:TemplateColumn>

</Columns>
</asp:DataGrid>
<asp:HiddenField ID="hidSelectedID" runat="server" />